<?php
require_once("../../../config.inc.php");
$isReloadable = true;
require_once("../../../app/_inc/include.php");


$errMsg = sxREQ('msg');

$sSQL = "SELECT m.module, m.description FROM  module m ORDER BY m.module";
$objSDAO->query($sSQL, "mp");
$aModZ = array();
while($row = $objSDAO->fetch("mp")) {
	$aModZ[$row['module']] = $row['module']." - ".$row['description'];
}
reset($aModZ);
$module = sxREQUEST('mod');
if($module==''){
	$module = sxVx($objUser->aSV,'crulList','mod');
	if($module==''){
		$module = key($aModZ);
	}
} 
$_REQUEST['mod'] = $module;
$objUser->aSV['crulList']['mod'] = $module;

if(sxREQUEST("mod")==''){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true)."&msg=".urlencode(_t("variabile 'mod' non passata")); 
	serverRedir($url);
}
//carico l'elenco
$sSQL = "SELECT cm.*, m.description AS descr_module FROM com_rule cm 
		INNER JOIN module m ON m.module=cm.module
		$sWHERE ORDER BY module, name";
$errMsg = "";
if(!$query = $objSDAO->query($sSQL, "sel")){
	$errMsg = $objSDAO->error;
	$errCode = $objSDAO->errno;
}
$row = $objSDAO->fetch("sel");
//output HTML
$aOpz = array("kMenu"=>'pro.cru', "isReloadable"=>true);
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"labl01\" width='20%'>"
			."<a class=\"labl01\" href=\"../modl/moduleView.php?mod=$module&xsn=".XSN."\">Module</a></td>"
			."<td class='text01' width='80%'>".getHtmlSelect('mod',$aModZ,'@REQ',$aOptCM)."</td></tr>");
echo "</table>\n";
$aCmd = array("ins"=>array("pag"=>"crulIns.php?mod=$module",
										"title"=>"new rule",
										"text"=>"new rule",
										"perm"=>"newfun"),
					"back"=>array()
					);
$sCmd = (commandsHTML($aCmd));	
echo $sCmd;	

echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"2\">List of Common Rules</td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"20%\">Code</td>" .
		"<td class=\"tabh01\" width=\"80%\">Description</td>" .
	"</tr>\n");	
while($row){
	echo("<tr>" .
				"<td class=\"text01\" valign='top'><a class=\"text01\" ".
					goToPag("crulView.php?mod=".$row["module"]."&name=".$row["name"]."&xsn=".XSN).
					" title=\""._t("visualizza la")." $pageSubject "."'".sxHE($row["description"])."'\">".
					$row["name"]."</a></td>\n" .
				"<td class=\"text01\" valign='top'>".sxHE($row["description"])."</td>" .
			"</tr>\n");
	$row = $objSDAO->fetch("sel");
}
echo("</table>\n");
echo $sCmd;	
echo(footerHTML());
exit();